from flask import Blueprint


class BaseRoute:
    """路由基类"""
    def __init__(self, name, url_prefix):
        self.name = name
        self.url_prefix = url_prefix
        self.bp = Blueprint(name, __name__, url_prefix=url_prefix)
    
    def register_routes(self, container):
        """注册路由，子类需要重写此方法"""
        raise NotImplementedError("子类必须实现 register_routes 方法")
    
    def get_controller(self, container, name):
        """从容器中获取控制器"""
        return container.get_controller(name)
    
    def get_service(self, container, name):
        """从容器中获取服务"""
        return container.get_service(name)